   
    <script>	
		$(document).ready(function(e) {
        	$("#save").click(function(){
				var gid=$("#gid").val();
				var rid=$("#rid").val();						
				var	detail=$("#detail").val();
				var datein=$("#start").val();
				var dateout=$("#end").val();
				
				//alert("Guest "+gid+" Room "+rid+" Detail "+detail+" DateIn "+datein+" DateOut "+dateout);			
			});
    	});	
	</script> 
    
    <?php
   	require_once("../action/connection.php");
	include("cmd/cmd.php");
   	$resid="";
   	if(isset($_GET['resid']))
		$resid=$_GET['resid'];
		$msg="";
		if ($resid==0){
			if(isset($_POST['btnsave'])){
				$res=new Reservation;
				$res->gue_id=$_POST['cboname'];
				$res->rom_id=$_POST['cboroom'];
				$res->datein=$_POST['datein'];
				$res->dateout=$_POST['dateout'];
				$res->note=$_POST['txtnote'];
				
				$msg=$res->new_reserv();
			
			}
		}else
			if(isset($_POST['btnsave'])){
				$re=new Reservation;
				$re->res_id=$resid;
				$re->gue_id=$_POST['cboname'];
				$re->rom_id=$_POST['cboroom'];
				$re->datein=$_POST['datein'];
				$re->dateout=$_POST['dateout'];
				$re->note=$_POST['txtnote'];
												
				$msg=$re->update_reserv();				
			}
		?>
    
            <h1 class="page-title"><?php if($resid==0){echo "New Reservation";} else{ echo"Edit Reservation";} ?></h1>
            <div><?php echo $msg; ?></div>
<div class="btn-toolbar">
    <!--<button class="btn btn-primary"><i class="icon-save"></i> Save</button>-->    
  <div class="btn-group">
  </div>
</div>
<div class="well">
    
    <div id="myTabContent" class="tab-content">
      <div class="tab-pane active in" id="home">
    <form method="post" id="tab">
        <label>Guest Name</label>
        <select name="cboname" id="gid" class="input-xlarge">
        <?PHP 
			 require_once("connection.php");
			
			$query = "SELECT * FROM guest_tbl"; 
			$result = mysql_query($query);	
			while($row = mysql_fetch_array($result)){
		 ?>
        	<option value=<?php echo $row['guest_id']; ?> ><?php echo $row['guest_name']; ?></option>
         <?php } ?>            
        </select> 
        <label>Room Number</label>
        <select name="cboroom" id="rid" class="input-xlarge">
        <?PHP 
			 require_once("connection.php");
			
			$query = "SELECT * FROM room_tbl"; 
			$result = mysql_query($query);	
			while($row = mysql_fetch_array($result)){
		 ?>
        	<option value=<?php echo $row['room_id']; ?> ><?php echo $row['room_no']; ?></option>
         <?php } ?>            
        </select> 
        
        
        <label>Date In</label>
        <input name="datein" id="start"  />
		<br><br>
        <label >Date Out</label>
        <input name="dateout" id="end" />
        <br><br>
            
        <!--<label>Date In</label>
        Day<select id="inday" class="input-mini">	<?php for($i=1;$i<=31;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
        Month<select id="inmonth" class="input-mini">	<?php for($i=1;$i<=12;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
        Year<select id="inyear" class="input-small">	<?php for($i=2014;$i<=2025;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
        <label>Date Out</label>
        Day<select id="oday" class="input-mini">	<?php for($i=1;$i<=31;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
        Month<select id="omonth" class="input-mini">	<?php for($i=1;$i<=12;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
        Year<select id="oyear" class="input-small">	<?php for($i=2014;$i<=2025;$i++){ ?><option value=<?php echo $i; ?>><?php echo $i; ?></option>  <?php } ?>  </select>
       -->
        <label>Detail</label>
        <textarea name="txtnote" id="detail" rows="3" class="input-xlarge" required></textarea>
        <br><button name="btnsave" id="save" class="btn btn-primary"><i class="icon-save"></i> Save</button>      
            
    </form>
    
      </div>
     </div>
  </div>	
  
  
  
    <link href="../stylesheets/kendo.common.min.css" rel="stylesheet">
    <link href="../stylesheets/kendo.rtl.min.css" rel="stylesheet">
    <link href="../stylesheets/kendo.default.min.css" rel="stylesheet">

    <script src="../javascripts/jquery.min.js"></script>
    <script src="../javascripts/kendo.web.min.js"></script>
    
    <script>
        
    </script>
    
        
    <script>
                $(document).ready(function() {
                    var today = new Date();
                    var start = $("#start").kendoDatePicker({
						value: today,
                        
                    });

                    var end = $("#end").kendoDatePicker({
						value: today,
                        
                    });

                    start.max(end.value());
                    end.min(start.value());
                });
            </script>
    
          

                       
		
